home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog5.arj / TEXTOUT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.9 KB  |  83 lines

  1. { textout.pas -- Text Output Methods }
  2.  
  3. program TextOutMethods;
  4.  
  5. uses WinTypes, WinProcs, WObjects, Strings;
  6.  
  7. type
  8.  
  9.   TextApplication = object(TApplication)
  10.     procedure InitMainWindow; virtual;
  11.   end;
  12.  
  13.   PTextWindow = ^TextWindow;
  14.   TextWindow = object(TWindow)
  15.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  16.     procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
  17.       virtual;
  18.   end;
  19.  
  20. { TextApplication }
  21.  
  22. {- Initialize the application's window }
  23. procedure TextApplication.InitMainWindow;
  24. begin
  25.   MainWindow := New(PTextWindow, Init(nil, 'Text Output Methods'))
  26. end;
  27.  
  28. { TextWindow }
  29.  
  30. {- Initialize the application's window object }
  31. constructor TextWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  32. begin
  33.   TWindow.Init(AParent, ATitle);
  34.   with Attr do
  35.   begin
  36.     X := 20; Y := 20; W := 300; H := 300
  37.   end
  38. end;
  39.  
  40. {- Paint text in window }
  41. procedure TextWindow.Paint(PaintDC: HDC; var PaintInfo:
  42.   TPaintStruct);
  43. const
  44.   SConst = 'A constant string';
  45. var
  46.   S: String;
  47.   C: Array[ 0 .. 255 ] of Char;
  48. begin
  49.  
  50. {- Method 1: Display literal string }
  51.   TextOut(PaintDC, 10, 10, 'A literal string', 16);
  52.  
  53. {- Method 2: Display Pascal string variable }
  54.   S := 'A Pascal string variable';
  55.   TextOut(PaintDC, 10, 50, @S[1], Length(S));
  56.  
  57. {- Method 3: Display C-style char array }
  58.   S := 'A C-style char array';
  59.   StrPCopy(@C, S);
  60.   TextOut(PaintDC, 10, 90, C, StrLen(C));
  61.  
  62. {- Method 4: Display string constant }
  63.   TextOut(PaintDC, 10, 130, SConst, Length(SConst));
  64.  
  65. end;
  66.  
  67. var
  68.  
  69.   TextApp: TextApplication;
  70.  
  71. begin
  72.   TextApp.Init('TextApp');
  73.   TextApp.Run;
  74.   TextApp.Done
  75. end.
  76.  
  77.  
  78. {--------------------------------------------------------------
  79.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  80.   Revision 1.00    Date: 1/11/1991
  81. ---------------------------------------------------------------}
  82.  
  83.